import { detailApi } from "@/utils/api";

// 详情模块
const detailModule = {
  namespaced: true,
  state: {
    // 详情数据
    detailData: null,
  },
  mutations: {
    // 详情的同步函数
    getDetail(state, payload) {
      state.detailData = payload.result;
    },
  },
  actions: {
    // 详情数据的异步函数
    async getDetailAsync({ commit }, payload) {
      const res = await detailApi({ id: payload.id });
      commit("getDetail", res);
    },
  },
};

export default detailModule;
